package ch7;

interface Instrument5 {
    // Compile-time constant:
    int i = 5; // static & final

    // Cannot have method definitions:
    void play(); // Automatically public

    String what();

    void adjust();
}

/**
 * @author ANG.YU
 * @date 2020-08-12 11:55
 */
public class Music5 {
    static void tune(Instrument5 i) {
        i.play();
    }

    static void tuneAll(Instrument5[] e) {
        for (Instrument5 i : e) {
            tune(i);
        }
    }

    public static void main(String[] args) {
        Instrument5[] orc = new Instrument5[5];
        int i = 0;
        orc[i++] = new Wind5();
        orc[i++] = new Percussion5();
        orc[i++] = new Percussion5();
        orc[i++] = new Brass5();
        orc[i++] = new Woodwind5();
        tuneAll(orc);
    }
}

class Wind5 implements Instrument5 {
    @Override
    public void play() {
        System.out.println("Wind5.play()");
    }

    @Override
    public String what() {
        return "Wind5";
    }

    @Override
    public void adjust() {
    }
}

class Percussion5 implements Instrument5 {
    @Override
    public void play() {
        System.out.println("Percussion5.play()");
    }

    @Override
    public String what() {
        return "Percussion5";
    }

    @Override
    public void adjust() {
    }
}

class Stringed5 implements Instrument5 {
    @Override
    public void play() {
        System.out.println("Stringed5.play()");
    }

    @Override
    public String what() {
        return "Stringed5";
    }

    @Override
    public void adjust() {
    }
}

class Brass5 implements Instrument5 {
    @Override
    public void play() {
        System.out.println("Brass5.play()");
    }

    @Override
    public void adjust() {
        System.out.println("Brass5.adjust()");
    }

    @Override
    public String what() {
        return "Brass5";
    }
}

class Woodwind5 implements Instrument5 {
    @Override
    public void play() {
        System.out.println("Woodwind5.play()");
    }

    @Override
    public String what() {
        return "Woodwind5";
    }

    @Override
    public void adjust() {
    }
}
